#ifndef _NTCMAP_H_
#define _NTCMAP_H_
#include <Arduino.h>


// 分辨率 0.20 ==>  020   -20 ~ 70 
// 分辨率 0.10 ==>  010   50 ~ 50 

#define NTC_FBL  010   

// -20 ~ 70   0.2分辨率
#if (NTC_FBL == 020 )
const int ADC_NTC[] = {
935,934,933,932,931,930,929,928,927,926,
924,923,922,921,920,919,918,917,915,914,
913,912,911,910,908,907,906,905,903,902,
901,900,898,897,896,894,893,892,890,889,
888,886,885,884,882,881,879,878,877,875,
874,872,871,869,868,866,865,863,862,860,
859,857,855,854,852,851,849,847,846,844,
843,841,839,838,836,834,832,831,829,827,
826,824,822,820,819,817,815,813,811,810,
808,806,804,802,800,798,797,795,793,791,
789,787,785,783,781,779,777,775,773,771,
769,767,765,763,761,759,757,755,753,751,
749,747,745,743,741,739,737,735,732,730,
728,726,724,722,720,717,715,713,711,709,
707,704,702,700,698,696,693,691,689,687,
684,682,680,678,676,673,671,669,666,664,
662,660,657,655,653,651,648,646,644,641,
639,637,634,632,630,628,625,623,621,618,
616,614,611,609,607,604,602,600,597,595,
593,590,588,586,583,581,579,577,574,572,
570,567,565,563,560,558,556,553,551,549,
546,544,542,539,537,535,533,530,528,526,
523,521,519,517,514,512,510,507,505,503,
501,498,496,494,492,489,487,485,483,481,
478,476,474,472,469,467,465,463,461,459,
456,454,452,450,448,446,443,441,439,437,
435,433,431,429,426,424,422,420,418,416,
414,412,410,408,406,404,402,400,398,396,
394,392,390,388,386,384,382,380,378,376,
374,372,370,368,366,364,362,361,359,357,
355,353,351,349,348,346,344,342,340,338,
337,335,333,331,330,328,326,324,322,321,
319,317,316,314,312,311,309,307,305,304,
302,301,299,297,296,294,292,291,289,288,
286,284,283,281,280,278,277,275,274,272,
271,269,268,266,265,263,262,260,259,257,
256,255,253,252,250,249,247,246,245,243,
242,241,239,238,237,235,234,233,231,230,
229,227,226,225,224,222,221,220,219,217,
216,215,214,212,211,210,209,208,207,205,
204,203,202,201,200,198,197,196,195,194,
193,192,191,190,189,187,186,185,184,183,
182,181,180,179,178,177,176,175,174,173,
172,171,170,169,168,167,166,165,164,164,
163,162,161,160,159,158,157,156,155,154
} ;
#define Get_temper(adc_val) ({ \
    float rt ; \
    for (unsigned int i = 0 ; i < sizeof(ADC_NTC)/sizeof(ADC_NTC[0]) ; i++) { \
        if(adc_val >= ADC_NTC[i]) { \
            rt = 0.2*i  + (-20) ; \
            break ; \
        } \
    } \
    rt = rt ; \
})

#endif 

#if ( NTC_FBL == 010 ) 

const int ADC_NTC[] = {
570,568,567,566,565,564,563,561,560,559,
558,557,556,554,553,552,551,550,549,548,
546,545,544,543,542,541,539,538,537,536,
535,534,533,531,530,529,528,527,526,525,
523,522,521,520,519,518,517,515,514,513,
512,511,510,509,507,506,505,504,503,502,
501,500,498,497,496,495,494,493,492,491,
489,488,487,486,485,484,483,482,481,479,
478,477,476,475,474,473,472,471,469,468,
467,466,465,464,463,462,461,460,459,457,
456,455,454,453,452,451,450,449,448,447,
446,444,443,442,441,440,439,438,437,436,
435,434,433,432,431,430,429,427,426,425,
424,423,422,421,420,419,418,417,416,415,
414,413,412,411,410,409,408,407,406,405,
404,403,402,401,400,399,398,397,396,395,
394,393,392,391,390,389,388,387,386,385,
384,383,382,381,380,379,378,377,376,375,
374,373,372,371,370,369,368,367,366,365,
364,363,362,362,361,360,359,358,357,356,
355,354,353,352,351,350,349,348,348,347,
346,345,344,343,342,341,340,339,338,338,
337,336,335,334,333,332,331,330,330,329,
328,327,326,325,324,323,322,322,321,320,
319,318,317,316,316,315,314,313,312,311,
311,310,309,308,307,306,305,305,304,303,
302,301,301,300,299,298,297,296,296,295,
294,293,292,292,291,290,289,288,288,287,
286,285,284,284,283,282,281,281,280,279,
278,277,277,276,275,274,274,273,272,271
} ;

#define Get_temper(adc_val) ({ \
    float rt ; \
    for (unsigned int i = 0 ; i < sizeof(ADC_NTC)/sizeof(ADC_NTC[0]) ; i++) { \
        if(adc_val >= ADC_NTC[i]) { \
            rt = 0.1*i  + (20) ; \
            break ; \
        } \
    } \
    rt = rt ; \
})
#endif 


#endif 